//search.js
Page({
  data: {
    name: '',
    score: {
      id: '',
      clazz: '',
      number:'',
      name:'',
      score1:''
    },
    showView: false,

    array: ['七(5)班', '七(6)班', '八(5)班', '八(6)班'],
    index: 0
    },

  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
  })
  },

  onLoad: function (options) {
    // 生命周期函数--监听页面加载  
    showView: (options.showView == "true" ? true : false)
  }
  , onChangeShowState: function () {
    var that = this;
    that.setData({
      showView: (!that.data.showView)
    })
  },  

 //事件处理函数
  bindinput: function (e) {
    this.setData({
      name: e.detail.value
    })
  },

 singleclick: function (event) {

    var that=this;

    wx.request({
      url: 'https://changyu.jackyshao.cn/chengji/name', //仅为示例，并非真实的接口地址
      data: {
        name: this.data.name
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        that.setData({ score : res.data });

        if(res.data)
          that.setData({
            showView: (true)
          })
         else{
          that.setData({
            showView: (false)
          });
          wx.showModal({
          title: '提示',
          content: '对不起，查无此人，请重新输入。',
          showCancel: false
        })}

    }

    })

 }
  
});


